package com.xuetang9.t9.hotel.controller;


import com.xuetang9.t9.hotel.beans.Floor;
import com.xuetang9.t9.hotel.services.IFloorService;
import com.xuetang9.t9.hotel.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 楼层控制
 * @author pang
 */
@Controller
@RequestMapping("/floor")
@ResponseBody
public class FloorController {
    @Autowired
    private IFloorService floorService;

    /**
     * 获取全部的楼层附加
     * @return
     */
    @RequestMapping("/show")
    private ResponseResult floorListShow(){
        return floorService.findByAll();
    }

    /**
     * 获取全部的楼层
     * @return
     */
    @RequestMapping("/showfloor")
    private ResponseResult floorListShowFloor(){
        return floorService.findByFloorAll();
    }

    /**
     * 保存楼层
     * @return
     */
    @RequestMapping("/save")
    private boolean floorSave(@RequestBody Floor floor){
        return floorService.save(floor);
    }

    /**
     * 删除楼层
     * @return
     */
    @RequestMapping("/remove/{id}")
    private boolean floorRemove(@PathVariable("id") Integer id){
        return floorService.remove(id);
    }

    /**
     * 修改楼层
     * @return
     */
    @RequestMapping("/alter")
    private boolean floorAlter(@RequestBody Floor floor){
        return floorService.alter(floor);
    }

    /**
     * 查询单个楼层
     * @return
     */
    @RequestMapping("/one/{id}")
    private ResponseResult floorByOneShow(@PathVariable("id") Integer id){
        return ResponseResult.okResult(floorService.findById(id));
    }
}
